package com.example.sulingorder.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.example.sulingorder.entity.OrderCommodityEntity;
import com.example.sulingorder.service.OrderCommodityService;
import com.xiao.sulingpublic.utils.PageUtils;
import com.xiao.sulingpublic.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;




/**
 * 订单涉及商品 表
 *
 * @author wen
 * @email 1322127758@qq.com
 * @date 2022-03-11 14:25:53
 */
@RestController
@RequestMapping("sulingoxqg/ordercommodity")
public class OrderCommodityController {
    @Autowired
    private OrderCommodityService orderCommodityService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("sulingoxqg:ordercommodity:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = orderCommodityService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{orcId}")
    //@RequiresPermissions("sulingoxqg:ordercommodity:info")
    public R info(@PathVariable("orcId") Long orcId){
		OrderCommodityEntity orderCommodity = orderCommodityService.getById(orcId);

        return R.ok().put("orderCommodity", orderCommodity);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("sulingoxqg:ordercommodity:save")
    public R save(@RequestBody OrderCommodityEntity orderCommodity){
		orderCommodityService.save(orderCommodity);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("sulingoxqg:ordercommodity:update")
    public R update(@RequestBody OrderCommodityEntity orderCommodity){
		orderCommodityService.updateById(orderCommodity);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("sulingoxqg:ordercommodity:delete")
    public R delete(@RequestBody Long[] orcIds){
		orderCommodityService.removeByIds(Arrays.asList(orcIds));

        return R.ok();
    }

}
